import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ichinesereader/controller/schooladmin.dart';
import '../../themes/appTheme.dart';

class AccountListItem extends StatelessWidget {
  AccountListItem({Key? key}) : super(key: key);
  final SchoolAdminController _schoolAdminController = Get.find();

  @override
  Widget build(BuildContext context) {
    return Obx(() {
      if (_schoolAdminController.schoolOverviewData.value.schoolName != null) {
        return Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Container(
              margin: EdgeInsets.symmetric(vertical: 6.0),
              child: Container(
                margin: EdgeInsets.only(right: 12.0),
                child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text('Accounts'.tr,
                          style: TextStyle(
                            fontFamily: 'Montserrat',
                            color: Colors.white,
                            fontSize: 18.0,
                            letterSpacing: 1,
                          )),
                      ElevatedButton(
                          style: ButtonStyle(
                              minimumSize:
                                  MaterialStateProperty.all(Size(120.0, 30.0))),
                          child: Text(
                            'Manage'.tr,
                            textAlign: TextAlign.center,
                            style: TextStyle(
                                fontFamily: 'Montserrat',
                                fontSize: 12.0,
                                color: Get.isDarkMode
                                    ? Get.theme.primaryColorDark
                                    : Get.theme.primaryColorLight),
                          ),
                          onPressed: () {
                            if (GetPlatform.isWeb) {
                              Get.toNamed('/schooladmin/classes');
                            } else {
                              Get.offAllNamed('/schooladmin/classes');
                            }
                          }),
                    ]),
              ),
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                ////////////TOTAL CLASS DATA BLOCK//////////////////
                Expanded(
                  child: Container(
                    margin: EdgeInsets.only(right: 6.0),
                    padding: EdgeInsets.all(
                      12.0,
                    ),
                    decoration: BoxDecoration(
                      color: Get.isDarkMode
                          ? AppTheme.colors.darkTheme2
                          : Get.theme.primaryColorDark.withOpacity(0.1),
                      borderRadius: BorderRadius.circular(
                        6.0,
                      ),
                      boxShadow: [
                        BoxShadow(
                          blurRadius: 1,
                          spreadRadius: 1,
                          color: Get.isDarkMode
                              ? Colors.transparent
                              : Colors.black.withOpacity(0.1),
                          offset: Offset(1, 1),
                        ),
                      ],
                    ),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: [
                        Container(
                          margin: EdgeInsets.only(bottom: 3.0),
                          padding: EdgeInsets.symmetric(
                            horizontal: 12.0,
                            vertical: 1.0,
                          ),
                          decoration: BoxDecoration(
                              color: Get.isDarkMode
                                  ? Colors.black
                                  : Colors.black.withOpacity(0.1),
                              borderRadius: BorderRadius.circular(9.0)),
                          child: Text(
                            "Classes".tr,
                            maxLines: 1,
                            overflow: TextOverflow.fade,
                            style: TextStyle(
                                fontFamily: 'Montserrat',
                                fontSize: 14,
                                color: Get.isDarkMode
                                    ? Get.theme.primaryColorDark
                                    : Get.theme.primaryColorLight),
                          ),
                        ),
                        Text(
                          _schoolAdminController
                              .schoolOverviewData.value.classesInUse
                              .toString(),
                          style: TextStyle(
                              fontFamily: 'Montserrat',
                              fontSize: 27,
                              color: Colors.white),
                        )
                      ],
                    ),
                  ),
                ),
                //////////////TOTAL TEACHERS//////////////////////////
                Expanded(
                  child: Container(
                    margin: EdgeInsets.only(right: 6.0),
                    padding: EdgeInsets.all(12.0),
                    decoration: BoxDecoration(
                      color: Get.isDarkMode
                          ? AppTheme.colors.darkTheme2
                          : Get.theme.primaryColorDark.withOpacity(0.1),
                      borderRadius: BorderRadius.circular(
                        6.0,
                      ),
                      boxShadow: [
                        BoxShadow(
                          blurRadius: 1,
                          spreadRadius: 1,
                          color: Get.isDarkMode
                              ? Colors.transparent
                              : Colors.black.withOpacity(0.1),
                          offset: Offset(1, 1),
                        ),
                      ],
                    ),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: [
                        Container(
                          margin: EdgeInsets.only(bottom: 3.0),
                          padding: EdgeInsets.symmetric(
                            horizontal: 12.0,
                            vertical: 1.0,
                          ),
                          decoration: BoxDecoration(
                              color: Get.isDarkMode
                                  ? Colors.black
                                  : Colors.black.withOpacity(0.1),
                              borderRadius: BorderRadius.circular(9.0)),
                          child: Text(
                            "Teachers".tr,
                            maxLines: 1,
                            overflow: TextOverflow.fade,
                            style: TextStyle(
                                fontFamily: 'Montserrat',
                                fontSize: 14.0,
                                color: Get.isDarkMode
                                    ? Get.theme.primaryColorDark
                                    : Get.theme.primaryColorLight),
                          ),
                        ),
                        Text(
                          _schoolAdminController
                              .schoolOverviewData.value.totalTeachers
                              .toString(),
                          style: TextStyle(
                            fontFamily: 'Montserrat',
                            fontSize: 27.0,
                            color: Colors.white,
                          ),
                        )
                      ],
                    ),
                  ),
                ),
                ////////////////TOTAL STUDENTS DATA BLOCK////////////
                Expanded(
                  child: Container(
                    margin: EdgeInsets.only(right: 6.0),
                    padding: EdgeInsets.all(12.0),
                    decoration: BoxDecoration(
                      color: Get.isDarkMode
                          ? AppTheme.colors.darkTheme2
                          : Get.theme.primaryColorDark.withOpacity(0.1),
                      borderRadius: BorderRadius.circular(
                        6.0,
                      ),
                      boxShadow: [
                        BoxShadow(
                          blurRadius: 1,
                          spreadRadius: 1,
                          color: Get.isDarkMode
                              ? Colors.transparent
                              : Colors.black.withOpacity(0.1),
                          offset: Offset(1, 1),
                        ),
                      ],
                    ),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: [
                        Container(
                          margin: EdgeInsets.only(bottom: 3.0),
                          padding: EdgeInsets.symmetric(
                            horizontal: 12.0,
                            vertical: 1.0,
                          ),
                          decoration: BoxDecoration(
                              color: Get.isDarkMode
                                  ? Colors.black
                                  : Colors.black.withOpacity(0.1),
                              borderRadius: BorderRadius.circular(9.0)),
                          child: Text(
                            "Students".tr,
                            maxLines: 1,
                            overflow: TextOverflow.fade,
                            style: TextStyle(
                                fontFamily: 'Montserrat',
                                fontSize: 14.0,
                                color: Get.isDarkMode
                                    ? Get.theme.primaryColorDark
                                    : Get.theme.primaryColorLight),
                          ),
                        ),
                        Text(
                          _schoolAdminController
                              .schoolOverviewData.value.totalStudents
                              .toString(),
                          style: TextStyle(
                            fontFamily: 'Montserrat',
                            fontSize: 27.0,
                            color: Colors.white,
                          ),
                        )
                      ],
                    ),
                  ),
                ),
                ////////////////TOTAL ACCOUNT DATA BLOCK////////////
                Expanded(
                  child: Container(
                    margin: EdgeInsets.only(right: 12.0),
                    decoration: BoxDecoration(
                      color: Get.isDarkMode
                          ? AppTheme.colors.darkTheme2
                          : Get.theme.primaryColorDark.withOpacity(0.1),
                      borderRadius: BorderRadius.circular(
                        6.0,
                      ),
                      boxShadow: [
                        BoxShadow(
                          blurRadius: 1,
                          spreadRadius: 1,
                          color: Get.isDarkMode
                              ? Colors.black
                              : Colors.black.withOpacity(0.1),
                          offset: Offset(1, 1),
                        ),
                      ],
                    ),
                    child: Padding(
                      padding: const EdgeInsets.all(12.0),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          Container(
                            margin: EdgeInsets.only(bottom: 3.0),
                            padding: EdgeInsets.symmetric(
                              horizontal: 12.0,
                              vertical: 1.0,
                            ),
                            decoration: BoxDecoration(
                                color: Get.isDarkMode
                                    ? Colors.black
                                    : Colors.black.withOpacity(0.1),
                                borderRadius: BorderRadius.circular(9.0)),
                            child: Text(
                              "Accounts".tr,
                              maxLines: 1,
                              overflow: TextOverflow.fade,
                              style: TextStyle(
                                  fontFamily: 'Montserrat',
                                  fontSize: 14.0,
                                  color: Get.isDarkMode
                                      ? Get.theme.primaryColorDark
                                      : Get.theme.primaryColorLight),
                            ),
                          ),
                          Text(
                            _schoolAdminController
                                .schoolOverviewData.value.studentAvailable
                                .toString(),
                            style: TextStyle(
                                fontFamily: 'Montserrat',
                                fontSize: 27.0,
                                color: Get.isDarkMode
                                    ? Get.theme.primaryColorDark
                                    : Colors.white),
                          )
                        ],
                      ),
                    ),
                  ),
                )
              ],
            ),
          ],
        );
      } else {
        return Text('');
      }
    });
  }
}
